<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加商品分类</title>
<link rel="stylesheet"
	href="${ pageContext.request.contextPath }/css/goodstype.css" />
<!-- 引入Jquery -->
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/static/js/jquery-2.1.1.min.js"></script>
<!-- 引入样式 -->
<link
	href="${ pageContext.request.contextPath }/static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<script
	src="${ pageContext.request.contextPath }/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/js/goodstype.js"></script>

<script type="text/javascript">
var basepath= '${APP_PATH}';
		function edit(cid) {
			window.location.href = "${pageContext.request.contextPath}/admin/adminCategory_edit.action?cid="+cid;
		}
		function addCategory(){
				window.location.href = "${pageContext.request.contextPath}/admin/adminCategory_add.action";
		}
		function deletec(cid) {
			var r=confirm("确定删除吗？");
			if (r==true){
				window.location.href ="${pageContext.request.contextPath}/admin/adminCategory_delete.action?cid="+cid;
				alert("删除成功！");
			}
			else{
				alert("取消删除");
			}
		}
		function selectzl(cid){
			window.location.href = "${pageContext.request.contextPath}/admin/adminCategory_getzl.action?cid="+cid;
	}
		
		$(document).on("click", ".Edit_btn", function() {
			$("#myModal").modal({
				backdrop : "static"
			});
		});
function aa(){
	alert("添加成功！");
}	
</script>
</head>
<body>
	<div style="margin-left: 20px; padding-top: 15px;">
		<div class="b" style="float: left;">
			<form
				action="${pageContext.request.contextPath}/admin/adminCategory_getzl.action?cid=${c.cid }">
				<!-- 商品种类： -->
				<select name="cid"
					style="height: 34px; width: 120px; border-radius: 4px;">
					<c:forEach var="c" items="${categoryList}">
						<option value="${c.cid }">${c.cname}</option>
					</c:forEach>
				</select> &nbsp; <input class="btn btn-primary" type="submit" value="查询" />
			</form>
		</div>
		<div align="right" style="padding-right: 60px;">
			<!-- <input type="button" class="Edit_btn" value="+添加商品" onclick="addCategory()" /> -->
			<input type="button" class="btn btn-primary Edit_btn" value="+一级种类" />
		</div>
	</div>

	<div style="width: 96%; margin-left: 26px;">
		<form style="margin-top: 8px;">
			<table width="100%" align="center" id="table"
				class="table table-hover table-bordered table-striped">
				<thead>
					<tr align="center" bgcolor="#93b6bd">
						<th width="30%" style="text-align: center;">种类ID</th>
						<th width="30%" style="text-align: center;">一级分类名称</th>
						<th style="text-align: center;">操作</th>
					</tr>
				</thead>
				<tbody></tbody>
				<!-- 循环遍历 -->
				<c:forEach items="${categoryList }" var="c">
					<tr align="center">
						<td>${c.cid}</td>
						<td>${c.cname }</td>
						<td><button type="button" class="btn btn-primary btn-sm glyphicon glyphicon-pencil"
								onclick="edit(${c.cid})"></button>&nbsp;&nbsp;
							<%-- <button type="button" class="btn btn-danger btn-sm glyphicon glyphicon-trash"
								onclick="deletec(${c.cid})"></button>&nbsp;&nbsp; --%>
							<button type="button" class="btn btn-info btn-sm glyphicon glyphicon-asterisk"
								onclick="selectzl(${c.cid})"></button></td>
					</tr>
				</c:forEach>
			</table>
		</form>
	</div>

	<!-- 添加 -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">添加一级种类</h4>
				</div>
				<div class="modal-body">
					<form
						action="${pageContext.request.contextPath}/admin/adminCategory_save.action">
						<label class="col-sm-4 control-label" style="padding-top: 10px;">一级分类名称：</label>
						<p class="form-control-static" id="id">
							<input type="text" name="cname" placeholder="一级分类名称"
								style="height: 38px; width: 200px; border-radius: 4px;" />
						</p>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
								data-dismiss="modal">关闭</button>
							<button type="submit" class="btn btn-primary" onclick="aa()">添加</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	<%-- <div>
		第 ${csPageBean.page }/${csPageBean.totlePage}页
		<c:if test="${csPageBean.page!= 1}">
			<a
				href="${pageContext.request.contextPath }/admin/adminCategorySecond_findAllByPage.action?page=1">首页</a>|
			     	<a
				href="${pageContext.request.contextPath }/admin/adminCategorySecond_findAllByPage.action?page=${csPageBean.page-1}">上一页</a>
		</c:if>
		<c:forEach begin="1" end="${csPageBean.totlePage}" var="i">
			<c:choose>
				<c:when test="${csPageBean.page!=i}">
					<a
						href="${ pageContext.request.contextPath }/admin/adminCategorySecond_findAllByPage.action?page=${i}">${i}</a>
				</c:when>
				<c:otherwise>
					<span class="currentPage">${i}</span>
				</c:otherwise>
			</c:choose>
		</c:forEach>
		<c:if test="${csPageBean.page!=csPageBean.totlePage}">
			<a
				href="${pageContext.request.contextPath }/admin/adminCategorySecond_findAllByPage.action?page=${csPageBean.page+1}">下一页</a> |
							<a
				href="${pageContext.request.contextPath }/admin/adminCategorySecond_findAllByPage.action?page=${csPageBean.totlePage}">尾页</a>
		</c:if>
	</div> --%>
		<div align="center" style="color:red;"><h3>${error2 }</h3></div>
</body>
</html>


